package com.waterflow.xanner;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.CheckBox;

public class SettingsActivity extends Activity {

	static final String KEY_MUTE_ON = "settings_mute_on";
	static final String PREFERENCES_NAME = "settings_prefs";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_settings);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_settings, menu);
		return true;
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		CheckBox cb = (CheckBox) findViewById(R.id.mute_on);
		SharedPreferences prefs = getSharedPreferences(PREFERENCES_NAME,
				Context.MODE_PRIVATE);
		cb.setChecked(prefs.getBoolean(KEY_MUTE_ON, false));
	}

	public void updateMute(View view) {
		CheckBox cb = (CheckBox) findViewById(R.id.mute_on);
		SharedPreferences prefs = getSharedPreferences(PREFERENCES_NAME,
				Context.MODE_PRIVATE);
		Editor edit = prefs.edit();
		edit.putBoolean(KEY_MUTE_ON, cb.isChecked());
		edit.apply();
	}

}
